import Vue from 'vue'
import Router from 'vue-router'
const routerPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error=> error)
}
Vue.use(Router)

const RouterList = [
    {
        path: '/',
        redirect: '/content',
        meta:{
            title:'1',
        }
    },
    {
        path: '/apply',
        name: 'apply',
        component:()=>import('@/view/Registration/index3.vue'),
        meta:{
            title:'10',
        }
    },
    {
        path: '/test',
        name: 'test',
        component:()=>import('@/view/Registration/index3.vue'),
        meta:{
            title:'18',
        }
    },
    {
        path: '/adminApply',
        name: 'adminApply',
        component:()=>import('@/view/Registration/adminIndex.vue'),
        meta:{
            title:'100000',
        }
    },
    // {
    //     path: '/apply2',
    //     name: 'apply2',
    //     component:()=>import('@/view/Registration/index2.vue'),
    //     meta:{
    //         title:'17',
    //     }
    // },
    {
        path: '/content',
        name: 'content',
        component:()=>import('@/view/content'),
        meta:{
            title:'1',
        }
    },
    {
        path: '/training',
        name: 'training',
        component:()=>import('@/view/training'),
        meta:{
            title:'5',
        }
    },
    {
        path: '/regulations',
        name: 'regulations',
        component:()=>import('@/view/regulations'),
        meta:{
            title:'6',
        }
    },
     {
        path: '/healthregulations',
        name: 'healthregulations',
        component:()=>import('@/view/healthregulations'),
        meta:{
            title:'11',
        }
    },
    {
        path: '/about',
        name: 'about',
        component:()=>import('@/view/about'),
        meta:{
            title:'7',
        }
    },
    {
        path: '/regulations/details',
        name: 'regulations/details',
        component:()=>import('@/view/regulations/details'),
        meta:{
            
        }
    },
     {
        path: '/healthregulations/details',
        name: 'healthregulations/details',
        component:()=>import('@/view/healthregulations/details'),
        meta:{
            
        }
    },
    {
        path: '/training/details',
        name: '/training/details',
        component:()=>import('@/view/training/details'),
        meta:{
            
        }
    },
    {
        path: '/404',
        name: '404',
        component:()=>import('@/view/error/404.vue'),
    },
    {
        path: '*',
        redirect: '/404',
    }
]
const mobileRouter=[
    {
        path: '/',
        redirect: '/content',
    },
    {
        path: '/content',
        name: 'content',
        component:()=>import('@/mobile/home'),
    },
    {
        path: '/test',
        name: 'test',
        component:()=>import('@/mobile/Registration/index3.vue'),
    },
    {
        path: '/regulations',
        name: 'regulations',
        component:()=>import('@/mobile/regulations'),
    },
    {
        path: '/regulations/details',
        name: 'regulations/details',
        component:()=>import('@/mobile/regulations/details'),
    },
    {
        path: '/training',
        name: 'training',
        component:()=>import('@/mobile/training'),
        
    },
    {
        path: '/training/details',
        name: '/training/details',
        component:()=>import('@/mobile/training/details'),
    },
    {
        path: '/apply',
        name: 'apply',
        component:()=>import('@/mobile/Registration/index3.vue'),
    },
    {
        path: '/apply2',
        name: 'apply2',
        component:()=>import('@/mobile/Registration/index2.vue'),
    },
    {
        path: '/applyzaah',
        name: 'applyzaah',
        component:()=>import('@/mobile/Registration/components/zaah.vue'),
    },
    {
        path: '/applyzaah/zaahitem',
        name: 'zaahitem',
        component:()=>import('@/mobile/Registration/components/zaahitem.vue'),
    },
    {
        path: '/applyqdjsxy',
        name: 'applyqdjsxy',
        component:()=>import('@/mobile/Registration/regQDJSXY'),
    },
    // {
    //     path: '/404',
    //     name: '404',
    //     // component:()=>import('@/error/404.vue'),
    // },
    // {
    //     path: '*',
    //     redirect: '/404',
    // }
]
let userAgent
if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iOS|iPad|Backerry|WebOS|Symbian|Windows Phone|Phone)/i))) {
  userAgent = true
}else{
  userAgent=false
}
const createRouter = () => new Router({
    // mode: 'history', // 去掉url中的#号，需要服务器支持
    scrollBehavior: () => ({
      y: 0
    }),
    routes: userAgent?mobileRouter:RouterList
})
const router = createRouter()

export default router